import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";
import { dealUserRouter } from "@/router/utils";

type Result = {
  success: boolean;
  data: Array<any>;
};

export const getAsyncRoutes = () => {
  return new Promise<Result>((resolve, reject) => {
    http
      .request<any>("get", baseUrlApi("/login/tokenByDetail"))
      .then(res => {
        // 处理返回值
        let newData = {
          success: true,
          data: dealUserRouter(res.data?.menuList || [])
        };
        resolve(newData);
      })
      .catch(e => {
        reject(e);
      });
  });
  // return http.request<Result>("get", "/get-async-routes");
};
